package itheima.zuoye.Test7;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class test {
    public static void main(String[] args) {
        Collection<Student> c = new ArrayList<>( );
        c.add(new Student("张三", 22));
        c.add(new Student("李四", 26));
        c.add(new Student("张翠山", 38));
        c.add(new Student("赵六", 19));
        c.add(new Student("张三丰", 103));
        c.add(new Student("张无忌", 17));
        c.add(new Student("赵敏", 16));

        print( c);








    }
    public static void print(Collection<Student> c) {
        //所有姓张然后年龄大于18岁的
        Iterator<Student> it = c.iterator();
        System.out.println("===所有姓张的以及年龄大于18岁元素如下===");
        while (it.hasNext()){
            Student s = it.next();
            if (s.getName().startsWith("张") && s.getAge() > 18){
                System.out.println(s);
            }



        }


    }
}
